﻿using 依赖注入案例练习.ConfigService;

namespace 依赖注入案例练习;

public class MailService:IMailService
{
    private readonly ILog _log;
    //private readonly IConfig _config;
    private readonly IConfigReader _configReader;

    public MailService(ILog log, IConfig config,IConfigReader configReader)
    {
        //this._config = config;
        this._configReader = configReader;
        this._log = log;
    }

    public void Send(string title, string to, string body)
    {
        this._log.MessageLog("开始准备发送邮件");
        Console.WriteLine(
            $"用户名：{_configReader.GetValue("userName")}，密码:{_configReader.GetValue("password")}，服务器地址:{_configReader.GetValue("SMTP")}");
        Console.WriteLine($"发送邮件：{title},{to},{body}");
        this._log.MessageLog("邮件发送成功");
    }
}